home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / Utilities / Calc / lib / varargs.cal < prev   
Encoding:
Text File  |  1992-02-24  |  547 b   |  28 lines  |  [TEXT/????]

  1. /*
  2.  * Copyright (c) 1992 David I. Bell
  3.  * Permission is granted to use, distribute, or modify this source,
  4.  * provided that this copyright notice remains intact.
  5.  *
  6.  * Example program to use 'varargs'.
  7.  *
  8.  * Program to sum the cubes of all the specified numbers.
  9.  */
  10.  
  11. define sc()
  12. {
  13.     local s, i;
  14.  
  15.     s = 0;
  16.     for (i = 1; i <= param(0); i++) {
  17.         if (!isnum(param(i))) {
  18.             print "parameter",i,"is not a number";
  19.             continue;
  20.         }
  21.         s += param(i)^3;
  22.     }
  23.     return s;
  24. }
  25.  
  26. global lib_debug;
  27. if (!isnum(lib_debug) || lib_debug>0) print "sc(a, b, ...) defined";
  28.